#ifndef __TERRAIN_H__
#define __TERRAIN_H__

#include "../Utilities/utilities.h"
#include "Vertex.h"
#include "Shaders.h"
#include "HeightField.h"
#include "Object.h"

namespace TerrainDefine
{
#define TERRAIN_SCALE_XZ 20.0f
#define TERRAIN_SCALE_Y {0.25f * TERRAIN_SCALE_XZ}
#define MAP_HEIGHT 512
#define MAP_WIDTH 512
}

class Terrain : public cObject
{
private:
	HeightField m_HeightMapData;

	Shaders m_Shader;
	GLuint m_uiTexCount;
	float m_fDx;
	float m_fDz;
	float m_fWidth;
	float m_fHeight;
private:
	void LoadTexture2D(char **fileName, int iCount);
	void GenVertex(int iNumVertexRows, int iNumVertexCols, int iNumCellRows, int iNumCellCols, float fDx, float fDz);
	void GenIndices(int iNumVertexRows, int iNumVertexCols, int iNumCellRows, int iNumCellCols);
	void GenNormVector(int AID, int BID, int CID);
	void Scale(GLfloat x, GLfloat y, GLfloat z){}
public:
	Terrain();
	~Terrain();
	void Init(char *fileHeightMapSrc);
	void Draw(ESContext *esContext);
	float GetHeight(float x, float z);
};

#endif